<template>
	<view class="container">
		<top-back-navbar position="fixed" title="个人中心" background="#001b4d" color="#ffff"></top-back-navbar>
		<view class="content_top" @click="jump" data-src="/pages/member/info/face/face">
			<image v-if="user_value.avatar == ''" src="../../static/33.jpg" mode=""></image>
			<image v-else :src="user_value.avatar" mode=""></image>
			<view class="">
				<view class="">
					ID号:{{user_value.yqm}}
				</view>
				<view class="">
					电话:{{user_value.mobile}}
				</view>
				<view class="">
					昵称:{{user_value.nickname}}
				</view>
			</view>
		</view>
		<view class="content">
			<view class="content_box">
			<!-- 	<view class="u-f-ac input_item" @click="jump" data-src="../member/info/info">
					<view class="titles">会员资料</view>
					<u-icon name="arrow-right" size="28"></u-icon>
				</view> -->
				<view class="u-f-ac input_item" @click="jump" data-src="/pages/order/order?index=0&=">
					<view class="titles">订单提货</view>
					<u-icon name="arrow-right" size="28"></u-icon>
				</view>
				<view class="u-f-ac input_item" @click="jump" data-src="/pages/member/acommsion/projcommision/myteam">
					<view class="titles">我的社区</view>
					<u-icon name="arrow-right" size="28"></u-icon>
				</view>
				<view class="u-f-ac input_item" @click="jump" data-src="/pages/member/zfbPay/qianyuesx">
					<view class="titles">银行绑卡</view>
					<u-icon name="arrow-right" size="28"></u-icon>
				</view>
				<view class="u-f-ac input_item" @click="jump" data-src="../member/address/address">
					<view class="titles">地址管理</view>
					<u-icon name="arrow-right" size="28"></u-icon>
				</view>
				<view class="u-f-ac input_item" @click="jump" data-src="/pages/commission/qrcode/invite_code?type=yqm">
					<view class="titles">邀请码 &nbsp;&nbsp;&nbsp;{{user_value.yqm}}</view>
					<u-icon name="arrow-right" size="28"></u-icon>
				</view>
				<!-- <view class="u-f-ac input_item" @click="password">
					<view class="titles">设置登录密码</view>
					<u-icon name="arrow-right" size="28"></u-icon>
				</view> -->

			<!-- 	<view class="u-f-ac input_item" @click="jump" data-src="./about_us">
					<view class="titles">关于我们</view>
					<u-icon name="arrow-right" size="28"></u-icon>
				</view> -->

				<view class="u-f-ac input_item" @click="jump" data-src="/pages/commission/qrcode/invite_code?type=fxxys">
					<view class="titles">风险提示协议书</view>
					<u-icon name="arrow-right" size="28"></u-icon>
				</view>
				<view class="u-f-ac input_item" @click="jump" data-src="/pages/commission/qrcode/invite_code?type=fwxy">
					<view class="titles">用户服务协议</view>
					<u-icon name="arrow-right" size="28"></u-icon>
				</view>
				<view class="u-f-ac input_item" @click="jump" data-src="/pages/commission/qrcode/invite_code?type=ysxy">
					<view class="titles">用户隐私协议</view>
					<u-icon name="arrow-right" size="28"></u-icon>
				</view>
				
				<view class="input_item">
					<view class="titles" style="display: flex;width: 50%;justify-content: space-between;">
						<view class="">
							设置或更新
						</view>
						<view class="">
							版本V {{versionUrl.version}}
						</view>
					</view>

					<u-icon name="arrow-right" size="28"></u-icon>
				</view>

			</view>
			<view style="padding: 80rpx 30rpx;">
				<button type="primary" style="background-color: #32539b; width:100%;border-radius: 60rpx;"
					@click="logout" :loading="loading">退出</button>
			</view>
		</view>

		<!-- <tabbars :current="3"></tabbars> -->

	</view>
</template>

<script>
	export default {
		data() {
			return {
				openid: '',
				loading: false,
				user_value: {},
				versionUrl: ''
			}
		},
		onShow: function() {
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.get_bank_value()
					this.get_v()
				},
				fail: () => {}
			});
			uni.hideLoading()
		},
		methods: {
			get_bank_value() {
				var _this = this
				uni.request({
					url: `${this.$BASE_URL}/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member&app=1`,
					method: 'POST',
					data: {
						'openid': this.openid,
					},
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					success: res => {
						_this.user_value = res.data
						console.log(_this.user_value);

					},
					fail: () => {},
					complete: () => {}
				})
			},
			get_v() {
				uni.request({
					url: this.$BASE_URL +
						'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=acommsion.getappversion&app=1',
					method: 'POST',
					success: res => {
						this.versionUrl = res.data
						
						
					}

				})
			},
			jumpdata() {
				uni.request({
					url: this.$BASE_URL + '/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member&app=1',
					method: 'POST',
					data: {
						'openid': this.openid
					},
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					success: res => {
						console.log(res.data.mobile)

						if (!res.data.mobile) {
							uni.navigateTo({
								url: '../../member/bind/telephone'
							})
							return
						}
						if (res.data.status == 0) {
							uni.showToast({
								title: res.data.result.message,
								icon: "none"
							});
							setTimeout(() => {
								uni.navigateTo({
									url: '../../member/info/info'
								});
							}, 2000)
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			jump(e) {
				uni.navigateTo({
					url: e.currentTarget.dataset.src
				});
			},
			logout() {
				uni.showModal({
					content: "是否退出登录",
					confirmText: "确定",
					cancelText: "取消",
					success: res => {
						if (res.confirm) {
							uni.clearStorageSync()
							uni.reLaunch({
								url: '/pages/login/login'
							});
						}
					}
				})
			},
			password() {
				uni.navigateTo({
					url: '/pages/commission/qrcode/login_pwd'
				})
			},
			jumpsure() {
				uni.showModal({
					title: '',
					content: '清除成功',
					showCancel: false,
					confirmColor: "#DD524D",
					success() {
						return
					}
				})
			},
			checknew() {
				uni.showModal({
					title: '',
					content: '已经是最新的版本啦',
					showCancel: false,
					confirmColor: "#DD524D",
					success() {
						return
					}
				})
			}
		}
	}
</script>

<style lang="less">
	page {
		background-color: #f2f5fa;
	}

	.container {
		width: 100%;
		height: 100vh;
		;
		box-sizing: border-box;
	}

	.content {
		padding: 30rpx;
	}

	.content_top {
		padding: 30rpx;
		width: 100%;
		height: 15vh;

		display: flex;
		align-items: center;

		image {
			width: 100px;
			height: 100px;
			border-radius: 50px;
			margin-right: 25px;
		}
	}

	.content_box {
		background-color: #FFFFFF;
		border-radius: 20rpx;
		box-shadow: 0px 2px 8px 3px rgba(235, 235, 235, 0.4);
		padding: 0 30rpx;

		.input_item {
			height: 90rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.titles {
				width: 200rpx;
				margin-right: 30rpx;
			}
		}

		.u-f-ac {
			border-bottom: 1px solid #f2f5fa;
		}
	}
</style>

